/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rh;

import com.rh.game.World;

import com.rh.game.impl.DemoGame;

import com.rh.gui.jframe.JaydenJFrame;

/**
 *
 * @author Hayden
 */
public class Main {
    
    public static void main(String[] args)  {
        System.out.println("Begin");
        if (args != null)  {
            System.out.println(java.util.Arrays.asList(args));
        }
        else  {
            System.out.println("args is null");
        }
        
        World world = null;
        try  {
            if ((args != null) && (args.length > 0))  {
                world = DemoGame.getGameWorldFromFile(args[0]);
            }
            else  {
                world = DemoGame.getGameWorld();
            }            
        }
        catch (Throwable x)  {
            x.printStackTrace();
        }
        System.out.println(world);
        
        if (world != null)  {
            Main m = new Main();
            m.jframe(world);
        }
        
        System.out.println("End");
    }

    public void jframe(World world)  {
        final JaydenJFrame jf = new JaydenJFrame(world);
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                jf.createAndShowGUI();
            }
        });        
    }
}
